package com.zoweunion.mechanic.dao.order;

import com.zoweunion.mechanic.model.User;
import com.zoweunion.mechanic.util.*;
import com.zoweunion.mechanic.util.certificate.OperationCertificate;
import com.zoweunion.mechanic.util.certificate.OperationCertificateOrder;
import com.zoweunion.mechanic.util.certificate.OperationCertificateOrderDetail;
import com.zoweunion.mechanic.util.certificate.OrderPay;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Component
public interface CGOrderDao {

    /**
     * 根据查询条件计数
     *
     * @param reqMap
     * @return
     */
    int countBycondition(Map<String, Object> reqMap);

    /**
     * 根据订单状态条件分页查询
     *
     * @param reqMap
     * @return
     */
    List<Map<String, Object>> listByStatus(Map<String, Object> reqMap);

    /**
     * 判断仓库库存是否充足
     * @param reqMap
     * @return
     */
//	Map<String, Object> doJudge(Map<String, Object> reqMap);

    /**
     * 仓库库存不充足
     *
     * @param reqMap
     * @return
     */
    int doNoEnough(@Param("reqMap") Map<String, Object> reqMap);

    int insertParts(@Param("map") Map<String, Object> weixiubaoyangPartsMap);

    int insertBatchzjParts(@Param("map") List<Map<String, Object>> zengjianParts);

    int insertjsParts(@Param("map") Map<String, Object> jianshaoPartsMap);

    int insertxzParts(@Param("map") Map<String, Object> xinzengPartsMap);

    int updateOrderStatus(Map<String, Object> reqMap);

    int insertOrderDetail(@Param("order_id") String order_id, @Param("id") String uuid, @Param("handle_user") String handle_user);

    public int updateOrderDetail(Map<String, Object> reqMap);

    List<Map<String, Object>> getFaultListByByOrderId(Map<String, Object> reqMap);

    /**
     * 根据工单id获取工单原配件、追加配件的信息
     *
     * @param order_id
     * @return
     */
    List<Map<String, Object>> getOrderPartsByOrderId(@Param("order_id") String order_id);

    // 仓管删除配件类型
    int deleteParts(Map<String, Object> deleteParts);

    // 获取存储配件
    List<Map<String, Object>> getSavePartsList(Map<String, Object> reqMap);

    int insertOrderParts(@Param("map") CGOrderEntity insertParts);

    int updatePartsList(Map<String, Object> reqMap);

    int selectParts(CGOrderEntity insertParts);

    int insertTParts(@Param("parts") CGOrderEntity insertParts);

    List<Integer> selectPartsByTime();


    List<CGOrderEntity> selectPartsBySId(@Param("pDate") Integer pDate);

    List<CGOrderEntity> selectPartsByPId(@Param("partsId") String parts_id, @Param("sId") String s_id, @Param("pDate") Integer pDate);

    void insertPartsCount(@Param("parts") PartCountEntity build);

    List<Integer> selectPartsByOrder();

    List<CGOrderEntity> selectOrderPartsByTime();

    List<CGOrderEntity> selectPartsByPIds(@Param("partsId") String parts_id, @Param("sId") String s_id);

    List<CGOrderEntity> selectPartsCount();

    List<OrderCount> orderException();

    List<String> selectRepairMan(@Param("orderId") String orderId);

    Long insertOrderCount(OrderCount orderCount);

    boolean insertException(OrderException orderException);

    Map<String, Object> selectRepairTime(@Param("orderId") String orderId);

    Map<String, Object> selectOrderAppraise(@Param("orderId") String orderId);

    int selectPartsIs(@Param("orderId") String orderId);

    List<Integer> selectOrderTime(@Param("orderId") String orderId);

    List<OrderException> selectOrderCountHead(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                              @Param("s_id") String s_id);

    List<OrderCount> selectOrderCount(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                      @Param("s_id") String s_id);

    List<Map<String, Object>> selectOrderCountNormal(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                     @Param("s_id") String s_id);

    List<Map<String, Object>> selectOrderByException(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                     @Param("s_id") String s_id, @Param("u_id") String u_id, @Param("status") Integer status);


    List<Map<String, Object>> selectOrderByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                @Param("s_id") String s_id, @Param("u_id") String u_id,
                                                @Param("status") Integer status);

    Map<String, Object> selectPriceByOrder(@Param("strings") List<String> strings, @Param("startTime") Date startTime
            , @Param("endTime") Date endTime);

    OrderException selectPercentByUser(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                       @Param("s_id") String s_id, @Param("uSId") String uSId);

    OrderException selectPercentByUserTz(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                         @Param("s_id") String s_id, @Param("uSId") String uSId);

    OrderException selectPercentByUserCg(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                         @Param("s_id") String s_id, @Param("uSId") String uSId);

    List<OrderException> selectPercentByCg(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                           @Param("s_id") String s_id);

    List<OrderException> selectPercentByTz(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                           @Param("s_id") String s_id);

    List<OrderCount> selectPercentByXg(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                       @Param("s_id") String s_id);

    OrderException selectPercentByXgL(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                      @Param("s_id") String s_id, @Param("zx_id") String zx_id);

    String selectOrderPriceCount(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                 @Param("s_id") String s_id);

    List<OrderException> selectOrderCountPerson(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                @Param("s_id") String s_id);

    List<OrderException> selectOrderCountCg(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                            @Param("s_id") String s_id);

    List<OrderException> selectOrderCountTz(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                            @Param("s_id") String s_id);

    List<OrderCount> selectOrderCountXg(@Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                        @Param("s_id") String s_id);

    void updateTimeOuTDeploy(@Param("timeOutDeploy") TimeOutDeploy timeOutDeploy);

    int selectByLevelUser(@Param("timeOutDeploy") TimeOutLevel timeOutLevel);

    void insertTimeOutLevel(@Param("timeOutLevel") TimeOutLevel timeOutLevel);

    TimeOutDeploy selectTimeOuTDeploy(@Param("timeOutDeploy") TimeOutDeploy timeOutDeploy);

    List<TimeOutLevel> selectTimeOutLevel(@Param("timeOutDeploy") TimeOutLevel timeOutLevel);

    void deleteTimeOutLevel(@Param("timeOutDeploy") TimeOutLevel timeOutLevel);

    List<String> selectDictionariesBy();

    List<DictionariesFault> selectByDic();

    void insertDictionariesBy(@Param("build") DictionariesFault build);

    void insertDictionariesByNew(@Param("build") DictionariesFault build);

    List<DictionariesFault> selectDictionariesByList(@Param("parentId") String parentId, @Param("sid") String sid);

    Map<String, Object> selectDictionariesByInfo(@Param("parentId") String parentId, @Param("sid") String sid);

    int selectDictionDis(@Param("sid") String sid, @Param("dictionariesName") String dictionariesName);

    void updateDictionariesBy(@Param("dictionariesFault") DictionariesFault dictionariesFault);

    void deleteDictionaries(@Param("dictionariesFault") DictionariesFault dictionariesFault);

    List<DictionariesFault> selectFault();

    Integer insertCertificateOrder(@Param("order") OperationCertificateOrder order);

    List<Map<String, Object>> selectaa();

    List<String> selectbb(@Param("item")Map<String, Object> item);

    List<String> selectcc(@Param("item")String ids);

    void updateaa(@Param("s")String s,@Param("ids") String ids);

    void deletedd(@Param("ss")Long s);

    void insertCertificate(@Param("order")OperationCertificate order);

    void deleteCertificate(@Param("order")OperationCertificate order);

    List<OperationCertificate> selectCertificate(@Param("order")OperationCertificate order);

    int selectByCertificateName(@Param("order")OperationCertificate order);

    int selectByCertificateNameS(@Param("order")OperationCertificate order);

    void updateCertificate(@Param("order")OperationCertificate order);

    Integer insertCertificateOrderPay(@Param("order")OrderPay order);

    void updateCertificateOrder(@Param("orderId")String orderId, @Param("id")Long id);

    OperationCertificateOrder selectCertificateOrderInfo(@Param("orderId")String orderId);

    void updateCertificateOrderStatus(@Param("order")OperationCertificateOrder order);

    void updateCertificateByOrder(@Param("order")OperationCertificateOrder order);

    List<OperationCertificateOrder> selectCertificateBusiness(@Param("orderStatus")Integer orderStatus,
                                                              @Param("createUser")String createUser);

    void deleteCertificateOrderStatus(@Param("order")OperationCertificateOrder order);

    int updateCertificateExpress(@Param("order")OperationCertificateOrder order);

    void operationCertificateOrderDetail(@Param("orderDetail")OperationCertificateOrderDetail orderDetail);

    List<OperationCertificateOrderDetail> getCertificateDetailList(@Param("orderId") String orderId);

    void removeCertificateFail(@Param("orderId") String orderId,@Param("text")String text);

    List<OperationCertificateOrder> selectCertificateList(@Param("startTime")Date startTime
            , @Param("endTime")Date endTime,@Param("operationName")String operationName);

    List<OperationCertificateOrder> selectCertificateListGroup(@Param("startTime")Date startTime
            , @Param("endTime")Date endTime);

    /**
     * 根据number查地区名称
     * @param type
     * @param number
     * @return
     */
    Map<String,Object> getNameByNumber(@Param("type") int type, @Param("number")Integer number);

    List<Map<String, Object>> selectKateWorkHour();

    List<Map<String, Object>>  selectKateWorkDetail(@Param("item")Map<String, Object> item);

    void updateWorkHour(@Param("thingsId")String things_id,
                        @Param("sampleDate")String sample_date, @Param("workHour")String s);

    /**
     * 该单子是否含有子工单 如果有 这个工单就是返修工单
     * @param orderId
     * @return
     */
    int isParentOrder(String orderId);

    Map<String, Object> selectTradeByNo(@Param("tradeNo")String tradeNo);

    void updateTradePayStatus(@Param("tradeNo")String tradeNo, @Param("status")int i,@Param("orderType")int orderType);

    Map<String,Object> getOrder(String outTradeNo);

    Map<String,Object> getUserById(String createUserId);
}
